home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / Bonus / VCLZip / kp222_b5.exe / kpZipObj.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-07-23  |  15.7 KB  |  528 lines

  1. // Borland C++ Builder
  2. // Copyright (c) 1995, 1999 by Borland International
  3. // All rights reserved
  4.  
  5. // (DO NOT EDIT: machine generated header) 'kpZipObj.pas' rev: 5.00
  6.  
  7. #ifndef kpZipObjHPP
  8. #define kpZipObjHPP
  9.  
  10. #pragma delphiheader begin
  11. #pragma option push -w-
  12. #pragma option push -Vx
  13. #include <kpCntn.hpp>    // Pascal unit
  14. #include <Classes.hpp>    // Pascal unit
  15. #include <SysUtils.hpp>    // Pascal unit
  16. #include <Windows.hpp>    // Pascal unit
  17. #include <SysInit.hpp>    // Pascal unit
  18. #include <System.hpp>    // Pascal unit
  19.  
  20. //-- user supplied -----------------------------------------------------------
  21.  
  22. namespace Kpzipobj
  23. {
  24. //-- type declarations -------------------------------------------------------
  25. typedef Word cpltype[31];
  26.  
  27. typedef Word cpdtype[30];
  28.  
  29. typedef unsigned U_LONG;
  30.  
  31. typedef int LongInt;
  32.  
  33. typedef double Comp;
  34.  
  35. typedef __int64 BIGINT;
  36.  
  37. typedef char CharArray[2147483647];
  38.  
  39. typedef char *CharArrayPtr;
  40.  
  41. typedef Byte ByteArray[2147483647];
  42.  
  43. typedef Byte *ByteArrayPtr;
  44.  
  45. typedef int IntegerArray[32767];
  46.  
  47. typedef int *IntegerArrayPtr;
  48.  
  49. typedef int *IntPtr;
  50.  
  51. typedef Byte *BYTEPTR;
  52.  
  53. typedef Word *WORDPTR;
  54.  
  55. typedef short short_int;
  56.  
  57. #pragma pack(push, 1)
  58. struct shrinktype
  59. {
  60.     short Prefix_of[8195];
  61.     Byte Suffix_of[8195];
  62.     Byte Stack[8195];
  63. } ;
  64. #pragma pack(pop)
  65.  
  66. #pragma pack(push, 1)
  67. struct DataDescriptorType
  68. {
  69.     int Sig;
  70.     int crc32;
  71.     int compressed_size;
  72.     int uncompressed_size;
  73. } ;
  74. #pragma pack(pop)
  75.  
  76. typedef Byte f_array[256][64];
  77.  
  78. typedef Byte *f_arrayPtr;
  79.  
  80. struct huft;
  81. typedef huft *huftptr;
  82.  
  83. typedef huftptr *huftptrptr;
  84.  
  85. struct kpZipObj__1
  86. {
  87.     
  88.     union
  89.     {
  90.         struct 
  91.         {
  92.             huft *t;
  93.             
  94.         };
  95.         struct 
  96.         {
  97.             Word n;
  98.             
  99.         };
  100.         
  101.     };
  102. } ;
  103.  
  104. #pragma pack(push, 1)
  105. struct huft
  106. {
  107.     Byte e;
  108.     Byte b;
  109.     kpZipObj__1 v;
  110. } ;
  111. #pragma pack(pop)
  112.  
  113. typedef huft huftarray[1002];
  114.  
  115. typedef huft *huftarrayptr;
  116.  
  117. typedef Word llarraytype[316];
  118.  
  119. typedef Word *llarrayptr;
  120.  
  121. typedef Byte slidearray[32768];
  122.  
  123. typedef Byte *slidearrayptr;
  124.  
  125. #pragma pack(push, 1)
  126. struct work
  127. {
  128.     
  129.     union
  130.     {
  131.         struct 
  132.         {
  133.             Byte Slide[32768];
  134.             
  135.         };
  136.         struct 
  137.         {
  138.             shrinktype shrink;
  139.             
  140.         };
  141.         
  142.     };
  143. } ;
  144. #pragma pack(pop)
  145.  
  146. typedef AnsiString *pString;
  147.  
  148. typedef pString *ppString;
  149.  
  150. typedef AnsiString TZipFilename;
  151.  
  152. typedef AnsiString TZipPathname;
  153.  
  154. typedef void __fastcall (__closure *TNewDiskEvent)(System::TObject* Sender, Classes::TStream* &S);
  155.  
  156. #pragma pack(push, 1)
  157. struct SignatureType
  158. {
  159.     
  160.     union
  161.     {
  162.         struct 
  163.         {
  164.             Word ID1;
  165.             Word ID2;
  166.             
  167.         };
  168.         struct 
  169.         {
  170.             int Sig;
  171.             
  172.         };
  173.         
  174.     };
  175. } ;
  176. #pragma pack(pop)
  177.  
  178. #pragma pack(push, 1)
  179. struct local_file_header
  180. {
  181.     SignatureType Signature;
  182.     Word version_needed_to_extract;
  183.     Word general_purpose_bit_flag;
  184.     Word compression_method;
  185.     unsigned last_mod_file_date_time;
  186.     unsigned crc32;
  187.     int compressed_size;
  188.     int uncompressed_size;
  189.     Word filename_length;
  190.     Word extra_field_length;
  191. } ;
  192. #pragma pack(pop)
  193.  
  194. typedef local_file_header *localPtr;
  195.  
  196. #pragma pack(push, 1)
  197. struct central_file_header
  198. {
  199.     SignatureType Signature;
  200.     Word version_made_by;
  201.     Word version_needed_to_extract;
  202.     Word general_purpose_bit_flag;
  203.     Word compression_method;
  204.     unsigned last_mod_file_date_time;
  205.     unsigned crc32;
  206.     int compressed_size;
  207.     int uncompressed_size;
  208.     Word filename_length;
  209.     Word extra_field_length;
  210.     Word file_comment_length;
  211.     Word disk_number_start;
  212.     Word internal_file_attributes;
  213.     unsigned external_file_attributes;
  214.     int relative_offset;
  215. } ;
  216. #pragma pack(pop)
  217.  
  218. typedef central_file_header *centralPtr;
  219.  
  220. class DELPHICLASS TZipHeaderInfo;
  221. class PASCALIMPLEMENTATION TZipHeaderInfo : public Classes::TPersistent 
  222. {
  223.     typedef Classes::TPersistent inherited;
  224.     
  225. private:
  226.     bool DR;
  227.     Word Fversion_made_by;
  228.     Word Fversion_needed_to_extract;
  229.     Word Fgeneral_purpose_bit_flag;
  230.     Word Fcompression_method;
  231.     unsigned Flast_mod_file_date_time;
  232.     unsigned Fcrc32;
  233.     int Fcompressed_size;
  234.     int Funcompressed_size;
  235.     Word Ffilename_length;
  236.     Word FCextra_field_length;
  237.     Word FLextra_field_length;
  238.     Word Ffile_comment_length;
  239.     Word Fdisk_number_start;
  240.     Word Finternal_file_attributes;
  241.     unsigned Fexternal_file_attributes;
  242.     int Frelative_offset;
  243.     int Fcentral_offset;
  244.     AnsiString Ffilename;
  245.     AnsiString Fdirectory;
  246.     char *Ffilecomment;
  247.     bool FMatchFlag;
  248.     Byte FFileIsOK;
  249.     bool FSelected;
  250.     
  251. protected:
  252.     bool __fastcall GetHasComment(void);
  253.     bool __fastcall GetIsEncrypted(void);
  254.     bool __fastcall GetHasDescriptor(void);
  255.     char * __fastcall Getfilecomment(Classes::TStream* S);
  256.     int __fastcall GetLocalSize(void);
  257.     int __fastcall GetCentralSize(void);
  258.     void __fastcall Setfilename(AnsiString FName);
  259.     void __fastcall Setdirectory(AnsiString Directory);
  260.     void __fastcall SetFileComment(char * FComment);
  261.     
  262. public:
  263.     __fastcall TZipHeaderInfo(void);
  264.     __fastcall TZipHeaderInfo(centralPtr crec, AnsiString FName);
  265.     __fastcall TZipHeaderInfo(localPtr lrec, AnsiString FName);
  266.     __fastcall virtual ~TZipHeaderInfo(void);
  267.     virtual void __fastcall Assign(Classes::TPersistent* Source);
  268.     virtual void __fastcall AssignTo(Classes::TPersistent* Dest);
  269.     void __fastcall SetFromCentral(centralPtr crec, AnsiString FName);
  270.     void __fastcall SetFromLocal(localPtr lrec, AnsiString FName);
  271.     void __fastcall Clear(void);
  272.     void __fastcall SaveCentralToStream(Classes::TStream* S);
  273.     void __fastcall SaveLocalToStream(Classes::TStream* S);
  274.     bool __fastcall ReadCentralFromStream(Classes::TStream* &S, TNewDiskEvent NewDiskEvent);
  275.     bool __fastcall ReadLocalFromStream(Classes::TStream* S);
  276.     void __fastcall SetDateTime(System::TDateTime DateTime);
  277.     void __fastcall SetNewFileComment(AnsiString NewComment);
  278.     __property Word version_made_by = {read=Fversion_made_by, write=Fversion_made_by, nodefault};
  279.     __property Word version_needed_to_extract = {read=Fversion_needed_to_extract, write=Fversion_needed_to_extract
  280.         , nodefault};
  281.     __property Word general_purpose_bit_flag = {read=Fgeneral_purpose_bit_flag, write=Fgeneral_purpose_bit_flag
  282.         , nodefault};
  283.     __property Word compression_method = {read=Fcompression_method, write=Fcompression_method, nodefault
  284.         };
  285.     __property unsigned last_mod_file_date_time = {read=Flast_mod_file_date_time, write=Flast_mod_file_date_time
  286.         , nodefault};
  287.     __property unsigned crc32 = {read=Fcrc32, write=Fcrc32, nodefault};
  288.     __property int compressed_size = {read=Fcompressed_size, write=Fcompressed_size, nodefault};
  289.     __property int uncompressed_size = {read=Funcompressed_size, write=Funcompressed_size, nodefault};
  290.     __property Word filename_length = {read=Ffilename_length, write=Ffilename_length, nodefault};
  291.     __property Word Cextra_field_length = {read=FCextra_field_length, write=FCextra_field_length, nodefault
  292.         };
  293.     __property Word Lextra_field_length = {read=FLextra_field_length, write=FLextra_field_length, nodefault
  294.         };
  295.     __property Word file_comment_length = {read=Ffile_comment_length, write=Ffile_comment_length, nodefault
  296.         };
  297.     __property Word disk_number_start = {read=Fdisk_number_start, write=Fdisk_number_start, nodefault};
  298.         
  299.     __property Word internal_file_attributes = {read=Finternal_file_attributes, write=Finternal_file_attributes
  300.         , nodefault};
  301.     __property unsigned external_file_attributes = {read=Fexternal_file_attributes, write=Fexternal_file_attributes
  302.         , nodefault};
  303.     __property int relative_offset = {read=Frelative_offset, write=Frelative_offset, nodefault};
  304.     __property int central_offset = {read=Fcentral_offset, write=Fcentral_offset, nodefault};
  305.     __property AnsiString filename = {read=Ffilename, write=Setfilename};
  306.     __property AnsiString directory = {read=Fdirectory, write=Setdirectory};
  307.     __property bool MatchFlag = {read=FMatchFlag, write=FMatchFlag, nodefault};
  308.     __property bool HasComment = {read=GetHasComment, nodefault};
  309.     __property bool Encrypted = {read=GetIsEncrypted, nodefault};
  310.     __property bool HasDescriptor = {read=GetHasDescriptor, nodefault};
  311.     __property char * filecomment = {read=Ffilecomment, write=SetFileComment};
  312.     __property int LocalSize = {read=GetLocalSize, nodefault};
  313.     __property int CentralSize = {read=GetCentralSize, nodefault};
  314.     __property Byte FileIsOK = {read=FFileIsOK, write=FFileIsOK, nodefault};
  315.     __property bool Selected = {read=FSelected, write=FSelected, nodefault};
  316. };
  317.  
  318.  
  319. #pragma pack(push, 1)
  320. struct end_of_central
  321. {
  322.     int ID;
  323.     Word this_disk;
  324.     Word start_central_disk;
  325.     Word num_entries_this_disk;
  326.     Word num_entries;
  327.     int size_central;
  328.     int offset_central;
  329.     Word zip_comment_length;
  330. } ;
  331. #pragma pack(pop)
  332.  
  333. typedef end_of_central *end_of_centralPtr;
  334.  
  335. class DELPHICLASS TEndCentral;
  336. class PASCALIMPLEMENTATION TEndCentral : public Classes::TPersistent 
  337. {
  338.     typedef Classes::TPersistent inherited;
  339.     
  340. private:
  341.     #pragma pack(push, 1)
  342.     end_of_central Fecrec;
  343.     #pragma pack(pop)
  344.     
  345.     char *FZipComment;
  346.     int FZipCommentPos;
  347.     bool FModified;
  348.     
  349. protected:
  350.     bool __fastcall GetZipHasComment(void);
  351.     char * __fastcall GetZipComment(Classes::TStream* S);
  352.     int __fastcall GetEndCentralSize(void);
  353.     __property end_of_central ecrec = {read=Fecrec, write=Fecrec};
  354.     
  355. public:
  356.     __fastcall TEndCentral(void);
  357.     __fastcall virtual ~TEndCentral(void);
  358.     void __fastcall SetNewZipComment(AnsiString NewComment);
  359.     virtual void __fastcall Assign(Classes::TPersistent* Source);
  360.     virtual void __fastcall AssignTo(Classes::TPersistent* Dest);
  361.     void __fastcall SetFromEndCentral(end_of_centralPtr crec);
  362.     void __fastcall Clear(void);
  363.     void __fastcall SaveToStream(Classes::TStream* S);
  364.     bool __fastcall ReadFromStream(Classes::TStream* S);
  365.     __property int ID = {read=Fecrec.ID, write=Fecrec.ID, nodefault};
  366.     __property Word this_disk = {read=Fecrec.this_disk, write=Fecrec.this_disk, nodefault};
  367.     __property Word start_central_disk = {read=Fecrec.start_central_disk, write=Fecrec.start_central_disk
  368.         , nodefault};
  369.     __property Word num_entries_this_disk = {read=Fecrec.num_entries_this_disk, write=Fecrec.num_entries_this_disk
  370.         , nodefault};
  371.     __property Word num_entries = {read=Fecrec.num_entries, write=Fecrec.num_entries, nodefault};
  372.     __property int size_central = {read=Fecrec.size_central, write=Fecrec.size_central, nodefault};
  373.     __property int offset_central = {read=Fecrec.offset_central, write=Fecrec.offset_central, nodefault
  374.         };
  375.     __property Word zip_comment_length = {read=Fecrec.zip_comment_length, write=Fecrec.zip_comment_length
  376.         , nodefault};
  377.     __property bool ZipHasComment = {read=GetZipHasComment, nodefault};
  378.     __property int ZipCommentPos = {read=FZipCommentPos, write=FZipCommentPos, nodefault};
  379.     __property char * ZipComment = {read=FZipComment, write=FZipComment};
  380.     __property bool Modified = {read=FModified, write=FModified, default=0};
  381.     __property int EndCentralSize = {read=GetEndCentralSize, nodefault};
  382. };
  383.  
  384.  
  385. #pragma option push -b-
  386. enum TZipSortMode { ByName, ByFileName, ByDirectoryName, ByDate, ByCompressedSize, ByUnCompressedSize, 
  387.     ByRate, ByNone };
  388. #pragma option pop
  389.  
  390. class DELPHICLASS TSortedZip;
  391. class PASCALIMPLEMENTATION TSortedZip : public Kpcntn::TSortedObjectList 
  392. {
  393.     typedef Kpcntn::TSortedObjectList inherited;
  394.     
  395. private:
  396.     TZipSortMode FSortMode;
  397.     System::TDateTime FFilesDate;
  398.     
  399. public:
  400.     __fastcall TSortedZip(Classes::TDuplicates WithDuplicates);
  401.     virtual int __fastcall Compare(void * Key1, void * Key2);
  402.     __property TZipSortMode SortMode = {read=FSortMode, write=FSortMode, default=7};
  403.     __property System::TDateTime filesdate = {read=FFilesDate, write=FFilesDate};
  404. public:
  405.     #pragma option push -w-inl
  406.     /* TObjectList.CreateWithOptions */ inline __fastcall TSortedZip(bool DestroyObjects, int InitialCapacity
  407.         ) : Kpcntn::TSortedObjectList(DestroyObjects, InitialCapacity) { }
  408.     #pragma option pop
  409.     #pragma option push -w-inl
  410.     /* TObjectList.Destroy */ inline __fastcall virtual ~TSortedZip(void) { }
  411.     #pragma option pop
  412.     #pragma option push -w-inl
  413.     /* TObjectList.CreateFromStream */ inline __fastcall TSortedZip(const AnsiString FileName) : Kpcntn::TSortedObjectList(
  414.         FileName) { }
  415.     #pragma option pop
  416.     
  417. };
  418.  
  419.  
  420. //-- var, const, procedure ---------------------------------------------------
  421. static const Word PATH_LEN = 0x104;
  422. static const Word FILENAME_LEN = 0x100;
  423. static const Word MAX_USHORT = 0xffff;
  424. static const Word MAX_SHORT = 0x7fff;
  425. static const Shortint icUNDEFINED = 0x0;
  426. static const Shortint icFILEOK = 0x1;
  427. static const Shortint icFILEBAD = 0x2;
  428. static const Shortint STORED = 0x0;
  429. static const Shortint SHRUNK = 0x1;
  430. static const Shortint REDUCED1 = 0x2;
  431. static const Shortint REDUCED2 = 0x3;
  432. static const Shortint REDUCED3 = 0x4;
  433. static const Shortint REDUCED4 = 0x5;
  434. static const Shortint IMPLODED = 0x6;
  435. static const Shortint TOKENIZED = 0x7;
  436. static const Shortint DEFLATED = 0x8;
  437. extern PACKAGE System::SmallString<4>  comp_method[9];
  438. extern PACKAGE Word mask_bits[17];
  439. extern PACKAGE Word border[19];
  440. extern PACKAGE Word cplens[31];
  441. extern PACKAGE Word cplext[31];
  442. extern PACKAGE Word cpdist[30];
  443. extern PACKAGE Word cpdext[30];
  444. extern PACKAGE Word cplen2[64];
  445. extern PACKAGE Word cplen3[64];
  446. extern PACKAGE Word extra[64];
  447. extern PACKAGE Word cpdist4[64];
  448. extern PACKAGE Word cpdist8[64];
  449. extern PACKAGE Word L_table[5];
  450. extern PACKAGE Word D_shift[5];
  451. extern PACKAGE Word D_mask[5];
  452. extern PACKAGE Word B_table[256];
  453. extern PACKAGE unsigned CRC_32_TAB[256];
  454. static const int DEF_CENTSIG = 0x2014b50;
  455. static const int DEF_LOCSIG = 0x4034b50;
  456. static const int DEF_ENDSIG = 0x6054b50;
  457. static const Word INBUFSIZ = 0x8000;
  458. static const Word OUTBUFSIZ = 0x8000;
  459. static const Shortint BMAX = 0x10;
  460. static const Word N_MAX = 0x120;
  461. static const Shortint MAX_BITS = 0xd;
  462. static const Word HSIZE = 0x2000;
  463. static const Word WSIZE = 0x8000;
  464. static const Word ZWSIZE = 0x8000;
  465. static const Shortint UNKNOWN = 0x2;
  466. static const Shortint BINARY = 0x0;
  467. static const Shortint ASCII = 0x1;
  468. static const Shortint MIN_MATCH = 0x3;
  469. static const Word MAX_MATCH = 0x102;
  470. static const Shortint MAX_ZBITS = 0xf;
  471. static const Shortint LENGTH_CODES = 0x1d;
  472. static const Word LITERALS = 0x100;
  473. static const Word L_CODES = 0x11e;
  474. static const Shortint D_CODES = 0x1e;
  475. static const Shortint HASH_BITS = 0xf;
  476. static const Word MIN_LOOKAHEAD = 0x106;
  477. static const Word MAX_DIST = 0x7efa;
  478. static const Word HASH_SIZE = 0x8000;
  479. static const Word HASH_MASK = 0x7fff;
  480. static const Word WMASK = 0x7fff;
  481. static const Shortint FAST = 0x4;
  482. static const Shortint SLOW = 0x2;
  483. static const Word TOO_FAR = 0x1000;
  484. static const Shortint H_SHIFT = 0x5;
  485. static const Shortint EQUAL = 0x0;
  486. static const Shortint EOFile = 0xffffffff;
  487. static const Shortint MAX_BL_BITS = 0x7;
  488. static const Word END_BLOCK = 0x100;
  489. static const Shortint BL_CODES = 0x13;
  490. static const Shortint STORED_BLOCK = 0x0;
  491. static const Shortint STATIC_TREES = 0x1;
  492. static const Shortint DYN_TREES = 0x2;
  493. static const Word LIT_BUFSIZE = 0x8000;
  494. static const Word DIST_BUFSIZE = 0x8000;
  495. static const Shortint REP_3_6 = 0x10;
  496. static const Shortint REPZ_3_10 = 0x11;
  497. static const Shortint REPZ_11_138 = 0x12;
  498. static const Word HEAP_SIZE = 0x23d;
  499. static const Shortint SMALLEST = 0x1;
  500. static const Shortint STORE = 0x0;
  501. static const Shortint DEFLATEIT = 0x8;
  502. static const Shortint Buf_size = 0x10;
  503. static const Shortint INIT_BITS = 0x9;
  504. static const Word FIRST_ENT = 0x101;
  505. static const Word CLEAR = 0x100;
  506. static const Byte DLE = 0x90;
  507. extern PACKAGE int CENTSIG;
  508. extern PACKAGE int LOCSIG;
  509. extern PACKAGE int ENDSIG;
  510. extern PACKAGE Byte LOC4;
  511. extern PACKAGE Byte LOC3;
  512. extern PACKAGE Byte LOC2;
  513. extern PACKAGE Byte LOC1;
  514. extern PACKAGE Byte END4;
  515. extern PACKAGE bool __fastcall DRun(void);
  516. extern PACKAGE void __fastcall setZipSignatures(int csig, int lsig, int esig);
  517.  
  518. }    /* namespace Kpzipobj */
  519. #if !defined(NO_IMPLICIT_NAMESPACE_USE)
  520. using namespace Kpzipobj;
  521. #endif
  522. #pragma option pop    // -w-
  523. #pragma option pop    // -Vx
  524.  
  525. #pragma delphiheader end.
  526. //-- end unit ----------------------------------------------------------------
  527. #endif    // kpZipObj
  528.